package com.ruoyi.system.service.impl;

import com.ruoyi.system.entity.PreventionTaskNum;
import com.ruoyi.system.mapper.PreventionTaskNumMapper;
import com.ruoyi.system.service.PreventionTaskNumService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 危险化学品企业重大危险源安全包保责任人隐患排查任务清单(PreventionTaskNum)表服务实现类
 *
 * @author makejava
 * @since 2023-06-19 15:36:18
 */
@Service("preventionTaskNumService")
public class PreventionTaskNumServiceImpl implements PreventionTaskNumService {
    @Resource
    private PreventionTaskNumMapper preventionTaskNumMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PreventionTaskNum queryById(Integer id) {
        return this.preventionTaskNumMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param preventionTaskNum 筛选条件
     * @return 查询结果
     */
    @Override
    public List<PreventionTaskNum> queryByPage(PreventionTaskNum preventionTaskNum) {
        List<PreventionTaskNum> preventionTaskNums = this.preventionTaskNumMapper.queryAllByLimit(preventionTaskNum);
        return preventionTaskNums;
    }

    /**
     * 新增数据
     *
     * @param preventionTaskNum 实例对象
     * @return 实例对象
     */
    @Override
    public PreventionTaskNum insert(PreventionTaskNum preventionTaskNum) {
        this.preventionTaskNumMapper.insert(preventionTaskNum);
        return preventionTaskNum;
    }

    /**
     * 修改数据
     *
     * @param preventionTaskNum 实例对象
     * @return 实例对象
     */
    @Override
    public PreventionTaskNum update(PreventionTaskNum preventionTaskNum) {
        this.preventionTaskNumMapper.update(preventionTaskNum);
        return this.queryById(preventionTaskNum.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.preventionTaskNumMapper.deleteById(id) > 0;
    }
}
